<template>
  <!-- 设置 -->
  <div class="box">
    <!-- 头部 -->
    <div class="top">
      <span class="iconfont icon-chevron-thin-left" @click="getlog()"></span>
      <p>设置</p>
    </div>
    <!-- 登录账号 -->
    <div class="logins" @click="logins()">
      <img :src="data.img" alt="" />
      <div class="loglist">
        <span>{{ data.name }}</span>
        <p>{{ data.phone }}</p>
      </div>
      <p class="iconfont icon-chevron-thin-right"></p>
    </div>
    <!-- 列表 -->
    <ul class="datas">
      <li @click="addre()">
        <span>我的收货地址</span>
        <p class="iconfont icon-chevron-thin-right"></p>
      </li>
      <li>
        <span>账户与安全</span>
        <p class="iconfont icon-chevron-thin-right"></p>
      </li>
      <li>
        <span>支付</span>
        <p class="iconfont icon-chevron-thin-right"></p>
      </li>
      <li>
        <span>消息通知</span>
        <p class="iconfont icon-chevron-thin-right"></p>
      </li>
      <li>
        <span>帮助与反馈</span>
        <p class="iconfont icon-chevron-thin-right"></p>
      </li>
      <li>
        <span>商家注入</span>
        <p class="iconfont icon-chevron-thin-right"></p>
      </li>
    </ul>
    <!-- 切换账户 -->
    <div class="account" @click="swit()">切换账户</div>
    <!-- 退出登录 -->
    <van-button type="danger" class="quit" @click="outlog()"
      >退出登录</van-button
    >
  </div>
</template>
<script>
export default {
  data() {
    return {
      data: {
        img: JSON.parse(localStorage.getItem("token"))
          ? JSON.parse(localStorage.getItem("token")).img
            ? JSON.parse(localStorage.getItem("token")).img
            : "https://cdn.jsdelivr.net/gh/zmf-6/cdn//img/portraits.png"
          : "https://cdn.jsdelivr.net/gh/zmf-6/cdn//img/portrait.png",
        name: JSON.parse(localStorage.getItem("token"))
          ? JSON.parse(localStorage.getItem("token")).name
          : "未登录",
        phone: JSON.parse(localStorage.getItem("token"))
          ? JSON.parse(localStorage.getItem("token")).phone
          : "没有账号,因为还没有登录",
      },
    };
  },
  methods: {
    //点击头部返回
    getlog() {
      this.$router.go(-1);
    },
    //点击头像
    logins() {
      this.$router.push({ path: "/getsd" });
    },
    //点击我的收货地址
    addre() {
      // console.log('111')
      this.$router.push({ path: "/site" });
    },
    //点击切换账号
    swit() {
      this.$router.push({ path: "/login" });
    },
    //点击退出登录
    outlog() {
      this.$dialog
        .confirm({
          // title: "标题",
          message: "您确定退出登录吗",
        })
        .then(() => {
          // on confirm
          localStorage.removeItem("token");
          this.$router.push({ path: "/login",query:{
            path:"/my"
          } });
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>
<style scoped>
.box {
  width: 100%;
  height: 830px;
  /* height: 100vh; */
  z-index: 666;
  position: fixed;
  left: 0;
  top: 0;
  background: #f5f5f5;
}
.box .top {
  width: 100%;
  height: 3rem;
}
.top span {
  width: 10%;
  float: left;
  line-height: 3rem;
  margin-left: 0.3rem;
}
.top p {
  margin-left: 45%;
  line-height: 3rem;
}
.box .logins {
  width: 100%;
  height: 5rem;
  background: #ffffff;
}
.logins img {
  width: 4rem;
  height: 4rem;
  border-radius: 2rem;
  margin: 0.5rem 0 0 0.8rem;
  float: left;
}
.logins .loglist {
  width: 8rem;
  height: 3rem;
  float: left;
  margin: 1rem 0 0 0.8rem;
  color: #adadad;
}
.loglist span {
  font-size: 1rem;
}
.loglist p {
  margin-top: 0.2rem;
  font-size: 0.2rem;
}
.logins .iconfont {
  width: 1rem;
  height: 5rem;
  float: right;
  line-height: 5rem;
  color: #c8c8c8;
  margin-right: 0.5rem;
}
.box .datas {
  width: 100%;
  height: 24rem;
  background: #ffffff;
  margin-top: 1rem;
}
.datas li {
  width: 100%;
  height: 4rem;
  border-bottom: 1px solid #f5f5f5;
  line-height: 4rem;
}
.datas li span {
  float: left;
  margin-left: 0.4rem;
}
.datas li p {
  float: right;
  color: #c8c8c8;
  margin-right: 0.5rem;
}
.box .account {
  width: 100%;
  height: 3rem;
  background: #ffffff;
  text-align: center;
  line-height: 3rem;
  margin: 1.2rem 0 1rem 0;
}
.box .quit {
  width: 100%;
}
</style>
